<?
/**
 * Add User Template
 */
(basename($_SERVER['PHP_SELF']) == basename(__FILE__)) && die('Access Denied');

// title
$this->setTitle(WEB_APP_NAME . ' : ' . OPT_ADD);

// validate required template variables
$item = $this->getVar('user');
if (!($item instanceof User)) {
	$m = 'The required object data is missing.';
	die($this->getPageError($m));
	}

// Are there errors?
$hasErrors = (is_array($this->getErrors()) and count($this->getErrors()));

// generate boilerplate html
$class = '';
$this->addJs('js/menu.js');
?>
<?= $this->getPageHeader(); ?>
<? if ($hasErrors) { ?>
<div id="container-error">
<?= implode('<br />', $this->getErrors()); ?>
</div>
<? } ?>
<div align="center">
<div id="page-container">

<div id="container-medium">
<?= getMenuBars(OPT_ADD); ?>
</div>

<div id="container-small">
<div class="content-add">

<?= $this->getFormHeader('add_user','return validateSubmit()'); ?>
<?= $this->getFormBreadCrumbs(); ?>
<input type="hidden" name="<?= WA_QS_CONFIRM; ?>" value="yes">
<input type="hidden" name="DisplayName" value="">

<table cellpadding="2" cellspacing="2">
	<tr>
		<td class="category" colspan="2">
			Account Information
		</td>
	</tr>
	<tr>
		<th>
			<?= htmlspecialchars($item->getPropertyDescription('Login')); ?>
		</th>
		<td>
			<input type="text" name="Login" SIZE="30" value="<?= htmlspecialchars($item->getProperty('Login')); ?>">
		</td>
	</tr>
<?
$props = array('FirstName', 'LastName');
foreach($props as $prop) { ?>
	<tr>
		<th>
			<?= htmlspecialchars($item->getPropertyDescription($prop)); ?>
		</th>
		<td>
			<input type="text" name="<?= $prop; ?>" SIZE="30" value="<?= htmlspecialchars($item->getProperty($prop)); ?>" ONBLUR="ucword(this);">
		</td>
	</tr>
<? } ?>
	<tr>
		<td class="category" colspan="2">
			Account Settings
		</td>
	</tr>
<?
$props = array('Enabled', 'IsAdmin');
foreach($props as $prop) {
	$val  = (isset($_POST[$prop])) ? ' checked' : '';
?>
	<tr>
		<th>
			<?= htmlspecialchars($item->getPropertyDescription($prop)); ?>
		</th>
		<td>
			<input type="checkbox" name="<?= $prop; ?>"<?= $val; ?>>
		</td>
	</tr>
<? } ?>
	<tr>
		<td colspan="2" ALIGN="right">
			<input class="submit" type="submit" name="submit" value="Add User">
		</td>
	</tr>
</table>
<?= $this->getFormFooter(); ?>

</div> <!-- content-edit -->
</div> <!-- container-medium -->
</div> <!-- page-container -->
</div> <!-- center -->
<script type="text/javascript">
loadForm();
doMenuMsg('<?= OPT_ADD; ?>');
</script>
<?= $this->getPageFooter(); ?>
